﻿using System.Web;

namespace Diploma.Utils
{
    public enum PathType
    {
        Absolute,
        Virtual,
        AppDepending
    }

    public static class PathUtil
    {
        public static string WebSiteBaseUrl
        {
            get
            {
                string baseUrl = string.Format("{0}://{1}{2}/", HttpContext.Current.Request.Url.Scheme,
                                               HttpContext.Current.Request.Url.Authority,
                                               HttpContext.Current.Request.ApplicationPath);

                return baseUrl;
            }
        }

        public static string GetPath(PathType pathType, string appDependingPath)
        {
            switch (pathType)
            {
                case PathType.Absolute:
                    return HttpContext.Current.Server.MapPath(string.Format(@"~\{0}\", appDependingPath));
                case PathType.Virtual:
                    return string.Format(@"~\{0}\", appDependingPath);
                case PathType.AppDepending:
                    return appDependingPath;
                default:
                    return null;
            }
        }
    }
}